package org.example.gift.fallback;

import feign.hystrix.FallbackFactory;
import org.example.gift.client.LoginUserFeignClient;
import org.example.gift.domain.LoginUser;
import org.example.gift.enums.SystemErrorCode;
import org.example.gift.util.AjaxResult;
import org.springframework.stereotype.Component;

@Component
public class LoginUserFallback implements FallbackFactory<LoginUserFeignClient> {
    @Override
    public LoginUserFeignClient create(Throwable throwable) {
        throwable.printStackTrace();

        return new LoginUserFeignClient() {
            @Override
            public AjaxResult addOrUpdate(LoginUser loginUser) {
                return AjaxResult.error(SystemErrorCode.RESPONSE_CODE_400500);
            }
        };
    }
}